<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="js/axios-0.18.0.js"></script>
  <script src="js/vue-v2.6.10.js"></script>
</head>
<body>
<div id="app">
  <form>
      <span v-text="msg"></span>
    用户名 ：<input type="text" v-model="username" name="username"><br>
    密码 ：<input type="text" v-model="password" name="password"><br>
      <input type="button" value="登录1" @click="login">
      <input type="button" value="登录2" @click="login2">
  </form>
</div>
</body>
</html>

<script>
    new Vue({
        el: "#app",
        data: {
            username:'',
            password:'',
            msg:''
        },
        methods: {
            login(){
                axios.get("http://127.0.0.1:8080/login",{
                    params:{
                        username:this.username,
                        password:this.password
                    }
                }).then(resp=>{
                   if(resp.status == 200){
                       //跳转到index.html
                       this.msg = "登录成功";
                       //2:将用户信息保存在session 将json对象转为string
                       sessionStorage.setItem("user",JSON.stringify(resp.data));
                       window.setTimeout(function (){
                           location.href = "index.html";
                       },1500)

                   }
                })
            },

            login2(){
                axios.get("http://127.0.0.1:8080/login2",{
                    params:{
                        username:this.username,
                        password:this.password
                    }
                }).then(resp=>{
                    if(resp.status == 200){
                        //跳转到index.html
                        this.msg = "登录成功";
                        //2:将用户的uuid保存在session 将json对象转为string
                        sessionStorage.setItem("uuid",resp.data);
                        window.setTimeout(function (){
                            location.href = "index2.html";
                        },1500)

                    }
                })
            }
        },
    })
</script>